package com.example.kothin_study

import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.kothin_study.dao.later
import com.example.kothin_study.dao.open
import com.example.kothin_study.utils.showToast
import startActivity

class MainActivity : AppCompatActivity() {

    private val TAG = "MainActivity"
    val p by later {
        Log.d(TAG, "onCreate: ")
        "test later"

    }

    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {

        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
//        getSharedPreferences("data", Context.MODE_PRIVATE).open {
//            putString("name", "Tom")
//            putInt("age", 28)
//            putBoolean("married", false)
//        }

        var btn = findViewById<Button>(R.id.button)

//        startActivity<MainActivity2>(this){
//            putExtra("name","cy")
//            putExtra("age",20)
//
//        }

        btn.setOnClickListener {
//            this.p
            "你即将跳转...".showToast(this, Toast.LENGTH_LONG)
            startActivity<MainActivity2>(this){
                putExtra("name","cy")
                putExtra("age",20)
            }

        }



        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }
}